package designPatterns.com.course_design.scrapy.logger;

import java.util.HashMap;
import java.util.Map;

/**
 * @projectName DesignPattern
 * @className com.course_design.scrapy.logger.LogFactory
 * @description
 */

public class LogFactory {
    protected static Map<String, Log> instances = new HashMap<>();

    public static Log getInstance(Class<?> clz) {
        String className = clz.getSimpleName();
        Log instance = LogFactory.instances.get(className);
        if (instance == null) {
            //生成具体产品--logger
            instance = new ConcreteLogger(clz);
            LogFactory.instances.put(className, instance);
        }
        return instance;
    }
}
